package Problem4;

import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) {
		System.out.println(checkPalindrome(93109));
		ArrayList<Integer> palindromes = new ArrayList<Integer>();
		for (int i = 999; i > 0; i--) {
			for (int j = 999; j > 0; j--) {
				int checkThis = i * j;
				if (checkPalindrome(checkThis)){
					palindromes.add(checkThis);
				}
			}
		}
		Collections.sort(palindromes);
		System.out.println(palindromes.get(palindromes.size()-1));

	}
	public static boolean checkPalindrome(int num){
		char[] check = Integer.toString(num).toCharArray();
		boolean result = true;
		for (int i = 0; i < check.length/2; i++){
			int forward = check[i];
			int backward= check[check.length - i -1];
			if (forward != backward) {
				result = false;
				break;
			}
				
		}
			
		return result;
	}
}
